<!--
 * @Descripttion: 
 * @Author: yuxi
 * @Date: 2022-09-15 15:58:47
 * @LastEditors: yuxi
 * @LastEditTime: 2022-10-09 21:35:14
-->
<script>
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
import XYZLayer from './XYZLayer';
export default {
  name: 'MiningTiandituLayer',
  mixins: [XYZLayer],
  render () { return '' },
  props: {
    ak: {
      type: String,
      default () {
        return ''
      }
    },
    layerType: {
      type: String,
      default () {
        // vec_c vec_w 矢量底图	
        // cva_c cva_w 矢量注记	
        // img_c img_w 影像底图	
        // cia_c cia_w 影像注记	
        // ter_c ter_w 地形晕渲	
        // cta_c cta_w 地形注记	
        // ibo_c ibo_w 全球境界	
        // eva_c eva_w 矢量英文注记	
        // eia_c eia_w 影像英文注记	
        return 'vec_w' // 导出枚举 ？
      }
    },
  },
  computed: {
    server () {
      return Math.floor(Math.random() * 8)
    },
    _url () {
      return `http://t${this.server}.tianditu.gov.cn/DataServer?T=${this.layerType}&x={x}&y={y}&l={z}&tk=${this.ak}`
    }
  },
  methods: {
    load () {
      const { map } = this
      this.layer = new TileLayer({
        source: new XYZ({
          url: this._url
        }),
        properties: {
          layerName: this.layerName,
          addLayerControl: this.addLayerControl
        }
      })
      map.addLayer(this.layer)
      // this.$emit('ready', { map: this.map, layer: this.layer })
    }
  }
}
</script>

<style>

</style>